package com.tintuc24h.com;

import java.util.List;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;

import com.tintuc24h.adapter.NewAdapter;
import com.tintuc24h.models.RssItem;
import com.tintuc24h.untils.Variables;

public class NewsItemList extends ListActivity{
	
	private List<RssItem> items;
	
	@Override
	
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		Bundle bundle=getIntent().getExtras();
		int categories=bundle.getInt(Variables.CATEGORY);
		int paper=bundle.getInt(Variables.PAPER);
		setTitle(Variables.TINTUC_CATEGORIES[categories]);
		
		int key = paper + 1000 + categories;
		items= Variables.newhashmap.get(key);
		NewAdapter adapter=new NewAdapter(NewsItemList.this, Variables.ICONS[0], items);
		setListAdapter(adapter);
	
	}

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		// TODO Auto-generated method stub
		super.onListItemClick(l, v, position, id);
		Intent intent=new Intent(NewsItemList.this, News.class);
		intent.putExtra(Variables._LINK, items.get(position).getLink());
		startActivity(intent);
		
	}

}
